package com.work.daily.stream;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * Stream 的映射(map/flatMap)
 *
 * @author Shengkang.Mo
 * @create 2020-11-26 16:31
 */
public class Stream_5_3 {
    public static void main(String[] args) {
        //将两个字符数组合并成一个新的字符数组。
        List<String> list = Arrays.asList("m,k,l,a", "1,3,5,7");
        List<String> strings = list.stream().flatMap(s -> {
            //将每个元素转换成一个stream
            String[] split = s.split(",");
            Stream<String> stream = Arrays.stream(split);
            return stream;
        }).collect(Collectors.toList());

        System.out.println("处理前集合：" + list.size());
        System.out.println("处理好集合：" + strings.size());
    }
}
